$(document).ready(function(){
	$.ajax({
		url: "./student",
		dataType: "json",
		success: function(JData){
			$("#studentTable").jqGrid({
				data: JData, 
				datatype: "local",
				colNames: ['NAME','AGE'],
				colModel:[
				          {name:'name',index:'name', width:60, align:"center", resizable: true},
				          {name:'age',index:'age', width:90, align:"center", resizable: true}
				        ],
				rowNum: 5,
				caption: "This is a test",
				width: $(window).width() - 80,
				height: $(window).height() - 80
			});
//			$("#studentTable").trigger('reloadGrid');
//			$.each(JData, function(index, value){
//				var temp = "<tr>";
//				temp += "<td>" + value.name + "</td><td>" + value.age + "</td>";
//				$("#studentTable").append(temp);
//				$("#studentTable").jqGrid("addRowData", index + 1, this);
//			});
//			$("#studentTable").trigger('reloadGrid');
		},
		error: function(jqXHR, textStatus, errorThrown){
			alert("Json FAILED!!!");
		}
	});
	
	$(window).resize(function(){
		$("#studentTable").jqGrid("setGridWidth", $(window).width() - 80);
		$("#studentTable").jqGrid("setGridHeight", $(window).height() - 80);
	});
	
	$("button, #anc").button();
	$("p").dialog();
	$("#menuTest").menu();
});